package com.mq.provider.service.impl;

import com.mq.provider.service.ProviderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;
import javax.annotation.Resource;

/**
 * @Author：Administrator
 * @Date：2022/7/24/0024 12:12
 * @Versiion：1.0
 */
/**消息的输入源
 * @author Administrator*/
@EnableBinding(Source.class)
@Slf4j
public class ProviderServiceImpl implements ProviderService {

    @Resource
    @Output(Source.OUTPUT)
    private MessageChannel msgChannel;

    /**
     * 发送消息
     *
     * @param msg
     */
    @Override
    public boolean send(String msg) {
        return msgChannel.send(MessageBuilder.withPayload(msg).build());
    }
}
